﻿using BUS;
using DTO;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FastDeal
{
    public partial class menu : System.Web.UI.UserControl
    {
        DiaPhuong _madiaphuong = new DiaPhuong();

        List<DiaPhuong> dp = new List<DiaPhuong>();
        DiaPhuong_BUS db1 = new DiaPhuong_BUS();
        protected void Page_Load(object sender, EventArgs e)
        {
            dp = db1.LayDanhSach_DiaPhuong();
            DropDownList1.DataSource = dp;
            DropDownList1.DataValueField = "MaDiaPhuong";
            DropDownList1.DataTextField = "TenDiaPhuong";
            DropDownList1.DataBind();

            foreach (DiaPhuong d in dp)
            {
                DropDownList1.Items.Add(d.TenDiaPhuong);
            }
            DropDownList1.DataBind();
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int index = int.Parse(DropDownList1.SelectedIndex.ToString());
            DiaPhuong d = dp[index];
            string url = "~/HienThiTheoKhuVuc.aspx?MaDiaPhuong=" + d.MaDiaPhuong.ToString();
            Response.Redirect(url);
        }
    }
}